<?php

namespace XWAM\Controller;

/**
 * ProductAlbumController 类
 *
 * @since 1.0 <2016-8-26> SoChishun <14507247@qq.com> Added.
 */
class ProductAlbumController extends AppbaseController {

    function image_list($product_id = 0) {
        if (!$product_id) {
            exit('参数无效!');
        }
        $m_image = new \XWAM\Model\ProductAlbumModel();
        $list = $m_image->get_paging_list($page, array('where' => array('product_id' => $product_id), 'order' => 'sort, id desc'));
        $product = $m_image->table('t_porg_product_goods')->field('id, title')->find($product_id);
        unset($m_image);
        $this->assign('product', $product);
        $this->assign('list', $list);
        $this->assign('page', $page->show());
        $this->display();
    }

    function image_edit($product_id = 0) {
        if (!$data) {
            $data = array('product_id' => $product_id, 'user_name' => $this->user_name, 'site_id' => $this->site_id);
        }
        $this->assign('data', $data);
        $this->display();
    }

    function image_edit_save() {
        $m_image = new \XWAM\Model\ProductAlbumModel();
        $result = $m_image->save_image();
        $this->dialogJump($result['status'], $result['info']);
    }

    function change_sort($id, $sort) {
        $m_image = new \XWAM\Model\ProductAlbumModel();
        $this->ajaxReturn($m_image->change_sort($id, $sort));
    }

    function image_delete($id = '') {
        $m_image = new \XWAM\Model\ProductAlbumModel();
        $this->ajaxReturn($m_image->delete_image($id));
    }

}
